//
//  ByModelOrderPay.m
//  itboye_shop_ios
//
//  Created by pro on 17/2/10.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByModelOrderPay.h"

@implementation ByModelOrderPay

- (void)setAttributes:(NSDictionary *)jsonDic{
    
    [super setAttributes:jsonDic];
    
    self.code           = jsonDic[@"pay_code"];
    self.key            = jsonDic[@"sign"];
    self.total_price    = [NSString stringWithFormat:@"%.2f",[jsonDic[@"pay_money"] floatValue]/100];
    
}

- (BOOL)isLegal {
    
    NSString *code = self.code;
    NSString *name = self.name;
    NSString *desc = self.desc;
    NSString *total_price = self.total_price;
    
    NSString *encode = [NSString stringWithFormat:@"%@%@%@%@", code, name, desc, total_price];
    NSString *encodeKey = [ByCoreCrypt pay_crypt:encode];
    
    return [encodeKey isEqualToString:self.key];
}


@end
